In today's society, the Internet has become an important medium for information exchange. Although the Internet is now very popular among the general public, it initially began as a system (or network) of interconnected computers used by government and academic researchers. An early problem of this network stemmed from the fact that the interconnected computers were not the same; they employed different hardware as well as different operating systems. Information exchange on such a heterogeneous network posed a communication problem. This problem was resolved through agreement on common standards, including protocols such as Transmission Control Protocol/Internet Protocol (TCP/IP) and HyperText Transfer Protocol (HTTP). These protocols enabled varied interconnected machines to share information in the form of static text or graphic documents.
These protocols, however, represented only two steps in the evolution of the Internet. Although users can exchange information documents among varied computers connected to the Internet, they cannot exchange executable application programs written in conventional languages such as C or C++, which are designed to interface with a particular processor (e.g., the Intel Pentium™ processor) and/or a particular operating system (e.g., Windows 95™ or DOS). This problem was solved with the advent of the Java™ programming language and its related runtime system.
Java is an object-oriented programming language that is described, for example, in a text entitled “The Java™ Tutorial” by Mary Campione and Kathy Walrath, Addison-Wesley, 1996. Importantly, Java is an interpreted language that is platform-independent-that is, its utility is not limited to one particular computer system. Using the Java programming language, a software developer writes programs in a form commonly called Java source code. When the developer completes authoring the program, he then compiles it with a Java compiler into an intermediate form called bytecode. Both the Java source code and the bytecode are platform-independent.
The compiled bytecode can then be executed on any computer system that employs a compatible runtime system that includes a virtual machine (VM), such as the Java virtual machine described in a text entitled “The Java Virtual Machine Specification,” by Tim Lindholm and Frank Yellin, Addison Wesley, 1996. The Java VM acts as an interpreter between the bytecode and the particular computer system being used. By use of platform-independent bytecode and the Java VM, a program written in the Java language can be executed on any computer system. This is particularly useful in networks such as the Internet that interconnect heterogeneous computer systems.
Interpreting bytecodes, however, make Java programs many times slower than comparable C or C++ programs. One approach to improving this performance is just-in-time (JIT) compilers. A JIT compiler is a compiler running as part of a Java virtual machine that dynamically translates bytecode to machine code just before a method is first executed. This can provide substantial speed-up over a system that just interprets bytecodes. A JIT compilation typically consists of a few phases executed in the following order: 1) byte-codes are converted to a platform-independent intermediate representation (IR); 2) the IR is transformed to an optimized IR using compiler optimization techniques; 3) the IR is converted to platform-dependent machine code.
Java virtual machine implementations are becoming very popular on devices with limited CPU and memory resources. On such devices, the above JIT compilation process has a few drawbacks. For example, the memory requirements of the compilation process may be prohibitive, because each of the stages has runtime memory requirements which may be excessive on a limited-resource device. Also, the memory requirements of storing each method's translation may be prohibitive. Therefore, JIT's on such devices will have to make decisions on which methods are really worthy of compilation, and will have to handle only those. In addition, some translations will have to be discarded to make room for new ones. This results in slower execution because re-translating is costly.
Another drawback is that runtime handling of byte-code to IR transformation and IR optimization may result in large compiler code sizes. Dynamic method selection online is also costly in terms of compiler code size.
Yet another drawback is that due to lower processing power on a limited resource machine, the optimization phase cannot do much work without slowing down user program execution considerably.
Accordingly, there is a need for a system and method for byte code compilation that is less memory intensive, results in faster compilation and execution, and reduces re-compilation cost.